﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace agile_tool.userControl
{
    /// <summary>
    /// Interaction logic for lineChart.xaml
    /// </summary>
    public partial class lineChart : UserControl
    {
        List<chartVal> lc = new List<chartVal>();
        public lineChart()
        {
            InitializeComponent();
        }
        int total = 0;

        public void addValue(int a, string b)
        {
            foreach (var f in lc)
            { 
                if(f.Name == b)
                {
                    f.val += a;
                    return;
                }
            }
            lc.Add(new chartVal(a, b));
        }

        public void createChart()
        {
            List<KeyValuePair<string, int>> valueList = new List<KeyValuePair<string, int>>();
            foreach (var f in lc)
            {
                valueList.Add(new KeyValuePair<string, int>(f.Name, f.val));
            }

            lineChart2.DataContext = valueList;
        }
        int count = 0;
        public void createChartProject(int total)
        {
            List<KeyValuePair<string, int>> valueList = new List<KeyValuePair<string, int>>();
            int realTotal=0;
            foreach (var f in lc)
            {
                realTotal += f.val;
           }


            valueList.Add(new KeyValuePair<string, int>("Start", realTotal));
            foreach (var f in lc)
            {
                count += f.val;
                valueList.Add(new KeyValuePair<string, int>(f.Name, realTotal - count));
            }

            lineChart2.DataContext = valueList;
        }
        private void btnExit_Click(object sender, RoutedEventArgs e)
        {

        }


    }

    public class chartVal
    {
        public chartVal(int a, string b)
        {
            val = a;
            Name = b;
        }
        public int val;
        public string Name;
    }
}
